package com.bjpowernode.boss.web.controller;

import com.bjpowernode.boss.common.enums.AjaxCode;
import com.bjpowernode.boss.web.service.LoginService;
import com.bjpowernode.boss.web.models.dto.LoginDto;
import com.bjpowernode.boss.web.models.form.LoginForm;
import com.bjpowernode.boss.web.models.menus.SubMenu;
import com.bjpowernode.boss.web.models.result.AjaxResult;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@ResponseBody
public class LoginController {
    @Resource
    LoginService loginService;
    @RequestMapping("/operator/LoginCheck")
    public AjaxResult LoginCheck(@RequestBody LoginForm loginForm){
        LoginDto loginDto = loginService.loginCheck(loginForm);
       return new AjaxResult(AjaxCode.LOGIN_SUCCESS,loginDto);
    }
    @RequestMapping("/operator/getMenus")
    public AjaxResult getMenus(@RequestHeader Long operatorId){
        List<SubMenu> menus = loginService.getMenus(operatorId);
        return new AjaxResult(AjaxCode.MENU_GET_SUCCESS,menus);
    }

}
